<template>
  <div v-if="visible" class="appointment-modal-overlay" @click="closeModal">
    <div class="appointment-modal" @click.stop>
      <!-- 关闭按钮 -->
      <div class="modal-header">
        <button class="close-btn" @click="closeModal">
          <div class="close-btn-bg"></div>
          <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#666" stroke-width="2">
            <line x1="18" y1="6" x2="6" y2="18"/>
            <line x1="6" y1="6" x2="18" y2="18"/>
          </svg>
        </button>
      </div>

      <!-- 插图 -->
      <div class="modal-illustration">
        <div class="illustration-bg">
          <!-- 医生图标 -->
          <div class="doctor-icon">
            <svg width="60" height="60" viewBox="0 0 100 100" fill="none">
              <!-- 医生头部 -->
              <circle cx="35" cy="30" r="12" fill="#FFB366"/>
              <!-- 医生身体 -->
              <rect x="25" y="38" width="20" height="30" rx="10" fill="#FFFFFF"/>
              <!-- 医生衣服 -->
              <rect x="27" y="42" width="16" height="20" rx="8" fill="#FF6B6B"/>
              <!-- 听诊器 -->
              <path d="M30 45 Q32 43 35 45" stroke="#4A90E2" stroke-width="2" fill="none"/>
              <circle cx="32" cy="47" r="2" fill="#4A90E2"/>
              <circle cx="35" cy="47" r="2" fill="#4A90E2"/>
            </svg>
          </div>
          
          <!-- 日历图标 -->
          <div class="calendar-icon">
            <svg width="70" height="70" viewBox="0 0 100 100" fill="none">
              <!-- 日历主体 -->
              <rect x="20" y="25" width="60" height="45" rx="8" fill="#FFFFFF"/>
              <!-- 日历顶部 -->
              <rect x="20" y="25" width="60" height="15" rx="8" fill="#5B73FF"/>
              <!-- 日历环 -->
              <rect x="35" y="15" width="4" height="20" rx="2" fill="#5B73FF"/>
              <rect x="65" y="15" width="4" height="20" rx="2" fill="#5B73FF"/>
              <!-- 日历格子 -->
              <rect x="25" y="50" width="8" height="6" rx="1" fill="#E8E8E8"/>
              <rect x="37" y="50" width="8" height="6" rx="1" fill="#E8E8E8"/>
              <rect x="49" y="50" width="8" height="6" rx="1" fill="#E8E8E8"/>
              <rect x="61" y="50" width="8" height="6" rx="1" fill="#E8E8E8"/>
              <rect x="25" y="60" width="8" height="6" rx="1" fill="#E8E8E8"/>
              <rect x="37" y="60" width="8" height="6" rx="1" fill="#FF6B6B"/>
              <rect x="49" y="60" width="8" height="6" rx="1" fill="#E8E8E8"/>
              <rect x="61" y="60" width="8" height="6" rx="1" fill="#E8E8E8"/>
            </svg>
          </div>
        </div>
      </div>

      <!-- 标题 -->
      <div class="modal-title">现在预约</div>
      
      <!-- 描述 -->
      <div class="modal-description">
        您是要预约时间还是要预约特定的医生
      </div>

      <!-- 按钮组 -->
      <div class="modal-buttons">
        <!-- 预约时间按钮 -->
        <button class="appointment-time-btn" @click="appointmentTime">
          <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2">
            <circle cx="12" cy="12" r="10"/>
            <polyline points="12,6 12,12 16,14"/>
          </svg>
          预约时间
        </button>
        
        <!-- 分隔线 -->
        <div class="divider">
          <span>或</span>
        </div>
        
        <!-- 预约医生按钮 -->
        <button class="appointment-doctor-btn" @click="appointmentDoctor">
          <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#4A90E2" stroke-width="2">
            <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/>
            <circle cx="12" cy="7" r="4"/>
          </svg>
          预约一个特定的医生
        </button>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { defineProps, defineEmits } from 'vue'

interface Props {
  visible: boolean
}

const props = defineProps<Props>()

const emit = defineEmits<{
  close: []
  appointmentTime: []
  appointmentDoctor: []
}>()

const closeModal = () => {
  emit('close')
}

const appointmentTime = () => {
  emit('appointmentTime')
}

const appointmentDoctor = () => {
  emit('appointmentDoctor')
}
</script>

<style scoped>
.appointment-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
  backdrop-filter: blur(6px);
  animation: overlayFadeIn 0.3s ease;
}

.appointment-modal {
  background: white;
  border-radius: 32px;
  width: 100%;
  max-width: 400px;
  padding: 0;
  position: relative;
  animation: modalSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

@keyframes overlayFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: flex-end;
  padding: 16px 20px 0;
  position: relative;
}

.close-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 32px;
  height: 32px;
  opacity: 0.8;
}

.close-btn-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #f8f9fa;
  border-radius: 50%;
  opacity: 0;
  transition: all 0.2s ease;
}

.close-btn:hover {
  opacity: 1;
}

.close-btn:hover .close-btn-bg {
  opacity: 1;
  transform: scale(1.1);
}

.modal-illustration {
  display: flex;
  justify-content: center;
  padding: 20px 0 32px;
}

.illustration-bg {
  width: 160px;
  height: 160px;
  background: linear-gradient(135deg, #00D4FF 0%, #5B73FF 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 12px 40px rgba(91, 115, 255, 0.4);
}

.doctor-icon {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

.calendar-icon {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
}

.modal-title {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: #2C3E50;
  margin-bottom: 12px;
  padding: 0 24px;
  letter-spacing: -0.5px;
}

.modal-description {
  text-align: center;
  font-size: 16px;
  color: #7F8C8D;
  line-height: 1.5;
  margin-bottom: 36px;
  padding: 0 24px;
}

.modal-buttons {
  padding: 0 28px 36px;
}

.appointment-time-btn {
  width: 100%;
  height: 56px;
  background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
  color: white;
  border: none;
  border-radius: 18px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
  transition: all 0.3s ease;
  box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

.appointment-time-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

.appointment-time-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

.divider {
  text-align: center;
  margin: 24px 0;
  position: relative;
}

.divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, #E0E0E0 50%, transparent 100%);
}

.divider span {
  background: white;
  color: #BDC3C7;
  padding: 0 24px;
  font-size: 15px;
  font-weight: 500;
}

.appointment-doctor-btn {
  width: 100%;
  height: 56px;
  background: white;
  color: #4A90E2;
  border: 2px solid #4A90E2;
  border-radius: 18px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: all 0.3s ease;
}

.appointment-doctor-btn:hover {
  background: #F8FBFF;
  border-color: #357ABD;
  color: #357ABD;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.15);
}

.appointment-doctor-btn:active {
  transform: translateY(0);
  background: #E3F2FD;
}

/* 响应式设计 */
@media (max-width: 480px) {
  .appointment-modal {
    margin: 0 16px;
    border-radius: 24px;
  }
  
  .modal-title {
    font-size: 22px;
  }
  
  .modal-description {
    font-size: 15px;
  }
  
  .appointment-time-btn,
  .appointment-doctor-btn {
    height: 52px;
    font-size: 16px;
  }
  
  .illustration-bg {
    width: 140px;
    height: 140px;
  }
  
  .modal-buttons {
    padding: 0 24px 32px;
  }
}

@media (max-width: 360px) {
  .appointment-modal {
    max-width: 340px;
  }
  
  .modal-header {
    padding: 16px 20px 0;
  }
  
  .modal-buttons {
    padding: 0 16px 24px;
  }
}
</style>